from flask import Flask,request,render_template
import json



app=Flask(__name__)

@app.route('/')
def index():
    return "Hello World 中文"

# app.add_url_rule('/', 'index', index)

@app.route('/login')
def index_login():
    return render_template('login.html')

@app.route('/login/submit', methods=['POST'])
def index_login_submit():
    name = request.form.get('name')
    password = request.form.get('password')
    return name + " " + password

@app.route("/index/<int:id>", )
def index_args(id):
    if id == 1:
        res = {"ret": 0, "msg": "ok", "res": "我要返回中文1"}
        return json.dumps(res, ensure_ascii=False)
    elif id == 2:
        return 'second'
    elif id == 3:
        return 'thrid'
    else:
        return 'hello world!'


@app.route("/index/request", methods=['GET', 'POST'] )
def index_request():
    if request.method == 'GET':
        name = request.args.get('name')
        # return "render_template('index.html')"
        return " hello: " + name + " "
    elif request.method == 'POST':
        name = request.form.get('name')
        password = request.form.get('password')
        return name + " " + password



if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0', port=5000)